<?php
namespace app\admin\model;

use think\Model;

class Good extends Model
{
    protected $table = 'product';
    protected $autoWriteTimestamp = true;

    public function category()
    {
        return $this->hasOne('Category','id','category_id');

    }

    public function property(){

        return $this->hasOne('ProductProperty','product_id','id');
    }

    public function imgs(){

        return $this->hasOne('ProductImage','product_id','id');
    }

//    public function getMainImgUrlAttr($value)
//    {
//        return config('setting.img_prefix').$value;
//    }

    public static function good_del($ids)
    {
        if (!is_array($ids)) {

            $ids = explode(' ', $ids);
        }

        foreach ($ids as $k => $v) {

            $cate = Good::destroy($v);

            if (!$cate) return false;

        }

        return true;
    }


}